// 运行结果：
// Launching IPhone
// Launching MacBook
// Launching MIPhone
// Launching MIBook
public abstract class AbstractProduct {
    public abstract void launch();
}
public abstract class Computer extends AbstractProduct {
    // 可以添加电脑特有的方法
}
public abstract class Phone extends AbstractProduct {
    // 可以添加手机特有的方法
}
public class MacBook extends Computer {
    @Override
    public void launch() {
        System.out.println("Launching MacBook");
    }
}
public class MIBook extends Computer {
    @Override
    public void launch() {
        System.out.println("Launching MIBook");
    }
}
public class IPhone extends Phone {
    @Override
    public void launch() {
        System.out.println("Launching IPhone");
    }
}
public class MIPhone extends Phone {
    @Override
    public void launch() {
        System.out.println("Launching MIPhone");
    }
}
public abstract class AbstractFactory {
    public abstract Phone phone();
    public abstract Computer computer();
}
public class AppleFactory extends AbstractFactory {
    @Override
    public Phone phone() {
        return new IPhone();
    }

    @Override
    public Computer computer() {
        return new MacBook();
    }
}
public class MiFactory extends AbstractFactory {
    @Override
    public Phone phone() {
        return new MIPhone();
    }

    @Override
    public Computer computer() {
        return new MIBook();
    }
}
public class Client {
    public static void main(String[] args) {
        AbstractFactory appleFactory = new AppleFactory();
        Phone applePhone = appleFactory.phone();
        Computer appleComputer = appleFactory.computer();
        applePhone.launch();
        appleComputer.launch();

        AbstractFactory miFactory = new MiFactory();
        Phone miPhone = miFactory.phone();
        Computer miComputer = miFactory.computer();
        miPhone.launch();
        miComputer.launch();
    }
}
